home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Risc World 3
/
Risc World 3.iso
/
SOFTWARE
/
ISSUE4
/
POWERBASE
/
DOCS
/
Ch10-Utils
< prev
next >
Wrap
Text File
|
2001-10-29
|
10KB
|
171 lines
=================
Ch 10 − Utilities
=================
All the procedures described in this chapter will be found on the Utilities
submenu of the iconbar menu, enabling you to examine and alter the structure
of an existing database. Note that, if passwords have been set, you need to
enter the database with the “Manager” level password to obtain access to
this submenu.
10.1 Changing the Primary Key
--------------------------------
The primary key of a database is determined when it is created but is not
fixed for all time. The New primary key choice displays the same dialogue
box as was used for creating the primary key in the first place, but with
the addition of two radio buttons, whose function is described below. The
present key structure is shown. Simply alter it to what you require and
click on Create or type Return.
The first of the two radio buttons (Retain subfile structure) is selected by
default, making the records appear in the same subfiles as before. Any
subsidiary indices, therefore, will still be valid. If you deselect this
radio button with ADJUST (i.e. have neither button selected) then all the
records will be placed in the currently selected subfile and you will need
to rebuild your subsidiary indices.
Selecting the second button (Restore deleted records) also places the
records in the current subfile, but has the additional effect of recovering
“deleted” records, i.e. records which are still lurking in the Database file
but aren’t in the primary key index. You would need to use this option when
the primary key index is lost or corrupted. If the PrimaryKey file is
actually missing both radio buttons are shaded in order to enforce this
mode. Note that you cannot recover deleted records if the Blank record on
deletion switch is set in the Preferences window: the data has really gone
for good in this case.
10.2 Adjusting the record format
-----------------------------------
Minor changes can be made without rebuilding the database. Choose Adjust
format and the blank record window with the blue grid will be displayed.
Clicking MENU over this brings up the same menu as you used to create the
screen originally, but the Field definition window has some options shaded.
Thus you can’t delete fields, add new ones or alter the data lengths, but
you can re-position fields, change descriptors and tags, and alter the
visible lengths of data fields. You can also change the field type within
its class, e.g. an Alphanumeric field could be changed to a Numeric one
since both belong to the Editable class, or you could change a 2-state
Check-box to a 3-state one, but you couldn’t change either into a Calculated
field. When you have finished making the changes choose Quit design from the
menu.
10.3 Changing the record format
----------------------------------
This is more drastic, but it is not always possible to foresee future needs
and you may have to introduce a new field or lengthen an existing one. That
involves rebuilding the whole database. Powerbase actually builds a
completely new database under another name, leaving your original database
unchanged in case anything goes wrong, so make sure you have enough disc
space available. Choose New record format. The Reformat database window
will appear. Several options are now available:
• Enter the new database name and drag the database sprite to a filer
window. You will then be offered the record layout for editing, as
when creating a new database. Make the required modifications then
choose Quit design from the menu.
• If you already have a Form file in the new format drop it onto the
Reformat window where its name will appear. Enter the new database
name and drag the sprite to a filer window.
• Create a new database shell (which must have a different name from
the one to be reformatted) and copy your existing Form file into it.
Open this “database”, edit the layout and save the Form file. Open
the old database, call up the Reformat window and drop the new one
onto it. Its pathname will appear in the window. Finally click on
Reformat. This was the method used in versions of Powerbase prior to
7.52 and, although it still works with the latest version, it should
be regarded as obsolete.
Data from a field in the old database will be copied to a field in the new
one with the same tag. The new database must therefore retain the same tags
as the old for data which is to be common to both. A tag present in the old
database but not in the new is assumed to refer to a deleted field and the
associated data is not transferred. A field present in both databases but
with a shorter defined length in the new one will have its data truncated if
- 50 -
necessary. A tag present in the new database but not in the old is assumed
to be a new field and will be left blank. Before proceeding Powerbase will
inform you of any likely data loss due to deleted or shortened fields and
ask you if you wish to proceed. When the process is complete you will be
left with the new database open. Links to validation tables, calculation
formulae, and indices are preserved unless a relevant field was omitted from
the new record.
10.4 Merging two databases
-----------------------------
Two databases may be merged provided they have identical record structures.
With the first database open, select Merge database and drag the second
database to the displayed window. The pathnames of both databases can now be
seen. The pathname of the open database is duplicated in a writable icon
labelled Save as. If you accept this default the data from the second
database will be merged into the open one. You can, however, change this
name and drag the database icon to a directory window. The merged data will
then go into a completely new database leaving both source databases as they
were. When you click on Merge databases Powerbase will check that the two
record formats are identical and report an error if they aren’t. An option
switch determines the action taken with regard to Sequence number fields
(see 8.4.1).
Two radio buttons are also present, as in the dialogue box for rebuilding
the primary key, and their functions are essentially the same (see 10.1).
Having the first button selected merges records into the same subfiles as
those they occupied in the second database. Having neither selected merges
records into the current subfile of the first database, regardless of where
they are in the second database. Having the second button selected does the
same, but also imports records which were “deleted” in the second database.
10.5 Changing the Database Length
------------------------------------
The number of available records in a database may be increased or decreased.
Change length leads to a window with two writable icons. The first specifies
the new database length, the other determines the number of records by
which the database will be lengthened each time it becomes full. If this
value is zero no automatic lengthening occurs; a warning is displayed
instead. You will only be allowed to shorten a database if the surplus
records have never been used or have been blanked on deletion. Otherwise
you can only get rid of them by exporting all the current records as a
subset (see 13.2)
10.6 Inspecting and balancing index trees
--------------------------------------------
Print index lets you examine the structure of the current index to find out
how many keys are present in each level. The ideal numbers in a
perfectly-balanced index tree are 1, 2, 4, 8, 16, 32, 64, 128 etc. (i.e.
powers of 2, beginning with 20.) A submenu gives you the option of printing
the actual keys, positioned according to the level they occupy in the tree,
or printing only the total number of nodes in each level.
The data printed is for all subfiles of the current key, but there is an
option to restrict it to the current subfile. There are also two
alternatives for the layout of the complete tree. Output is to a screen
window from which it may be saved in the same way as any other report. (If
you have printed the keys themselves then double-clicking with SELECT on any
key will call up the associated database record.)
If the tree is very unbalanced and, especially, if there is an enormous
number of levels with only 1 or 2 keys in each, you are advised to balance
it using the Balance index choice*. It is also possible to make Powerbase
balance the index automatically at regular intervals. To turn on
auto-balancing choose Preferences from the iconbar menu. Select the
Balance every <n> records switch, placing your chosen value of n in the
writable icon provided, then click on Accept.
Auto-balancing is most likely to be useful when a large number of records
are being entered in primary-key order. This will happen if you are
entering data from a lot of forms in alphabetical order of name where name
is the primary key. It is also very likely to happen when importing CSV
files as these are often ordered according to the data item which becomes
the primary key field of the database record.
10.7 Finding duplicate primary keys
--------------------------------------
Wherever possible a primary key should be chosen so as to be unique. Where
duplication of the primary key might occur the designer of the database can
decide either to allow or forbid it (see 11.2.1). If duplicate keys are
permitted it is sometimes useful to have a list of them. Such a list is
created by Find duplicates and may be saved as a text file.
- 51 -